<template>
  <div>
    <TableComponent :columns="columns" :requestFn="fetchTableData">
      <template #handleOpt>
        <div class="mb10 wfull flex justify_end">
          <!-- 新增店铺 -->
          <el-button type="primary" @click="handleAddStore">{{ $t("customerInfoMation_addStore") }}</el-button>
        </div>
      </template>
    </TableComponent>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref } from "vue";
import { TableItemDataType } from "../../../../viewModel/TableComponent/TableComponent";
import {useI18n} from "vue-i18n"
import { useRouter } from "vue-router"
export default defineComponent({
  setup() {
    const { t } = useI18n()
    const router = useRouter()
    const columns = ref<TableItemDataType[]>([
      {
        label: t("customerInfoMation_client"), // 客户名称
        prop: "customerName",
      },
      {
        label: t("customerInfoMation_shopNames"), // 店铺名称
        prop: "shopName",
      },
      {
        label: t("customerInfoMation_shopType"), // 店铺类型
        prop: "StoreType",
      },
      {
        label: t("customerInfoMation_subjectInformation"), // 主体信息
        prop: "subjectInformation",
        overflowToolTip: true
      },
      {
        label: t("customerInfoMation_storeContactPerson"), // 店铺联系人
        prop: "storeContactPerson",
      },
      {
        label: t("customerInfoMation_storeContactInformation"), // 店铺联系方式
        prop: "storeContactInformation",
      },
      {
        label: t("customerInfoMation_metaService"), // 元服务
        prop: "metaService",
      },
      {
        label: t("customerInfoMation_address"), // 地址
        prop: "address",
      }
    ]);

    const fetchTableData = (params: any) => {
      console.log("请求参数：", params);
      return {
        code: 200,
        data: [],
      };
    };
    
    // 新增店铺
    const handleAddStore = (payload: any) => {
      console.log("新增店铺：", payload);
      router.push("/baseLayout/storeAdd")
    };

    return {
      columns,
      fetchTableData,
      handleAddStore,
    };
  },
});
</script>

<style></style>
